using Cfg.Exceptions;
using Cfg.Helpers;

namespace Cfg.ValidationAttributes
{
    public class MinAttribute : CfgValueValidatorBaseAttribute
    {
        public object Min { get; private set; }

        public MinAttribute(object min, params string[] contexts)
        {
            Contexts = contexts;
            Min = min;
        }

        protected override void Validate(object value)
        {
            if (value.IsLessThan(Min))
                throw new OutOfBoundsException(string.Format("{0} exceeds min value {1}", value, Min));
        }
    }
}